package com.husd.framework.redis.impl;

import com.husd.framework.redis.RedisFailRetryService;

/**
 * @author hushengdong
 */
public class RedisFailRetryServiceImpl implements RedisFailRetryService {

    @Override
    public Object getHeadNodeFromList() {

        //String headStr = goodsPriceCache.lindex(listName, 0L);
        return null;
    }

    @Override
    public void pushDiscardId2Queue() {

        String queueName = "";
        //goodsPriceCache.lpush(queueName, String.valueOf(discardSerialNum));
    }

    @Override
    public void removeDiscardIdFromQueue() {

        String queueName = "";
        //goodsPriceCache.lrem(queueName, 0L, String.valueOf(id));
    }

    @Override
    public void process() {

        //最先失效的，永远排在最前面
        //失效队列的结构如下：
        //失效时间,售价流水号,售价流水号 失效时间,售价流水号,售价流水号 失效时间,售价流水号,售价流水号
        Object head = getHeadNodeFromList();
        while (head != null) {
            //执行失效逻辑
            dosomething();
            //移除头节点
            removeDiscardIdFromQueue();
            head = getHeadNodeFromList();
        }
    }

    private void dosomething() {

    }
}
